﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FilterExample
{
    class Program
    {
        delegate bool Filter(int value);
        static void Main(string[] args)
        {
            var array = Enumerable.Range(1, 100).ToArray();

            var oddArray = FilterArray(array, GetOdd);
            var evenArray = FilterArray(array, GetEven);
            var fiveMularray = FilterArray(array, Get5Mul);
        }

        static List<int> FilterArray(int[] array, /*Func<int, bool>*/Filter filter)
        {
            List<int> filteredValues = new List<int>();

            foreach (var item in array)
            {
                if (filter(item))
                {
                    filteredValues.Add(item);
                }
            }

            return filteredValues;
        }

        static bool GetOdd(int value) 
        {
            return value % 2 == 1;
        }

        static bool GetEven(int value)
        {
            return value % 2 == 0;
        }

        static bool Get5Mul(int value)
        {
            return value % 5 == 0;
        }
    }
}
